package com.ruoyi.web.controller.company;

import java.util.List;

import com.ruoyi.common.annotation.Anonymous;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.introduction.domain.Introduction;
import com.ruoyi.introduction.service.IIntroductionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司介绍Controller
 *
 * @author ruoyi
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/introduction/introduction")
public class IntroductionController extends BaseController
{
    @Autowired
    private IIntroductionService introductionService;

    /**
     * 查询公司介绍列表
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:list')")
    @GetMapping("/list")
    public TableDataInfo list(Introduction introduction)
    {
        startPage();
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        return getDataTable(list);
    }

    /**
     * 导出公司介绍列表
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:export')")
    @Log(title = "公司介绍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Introduction introduction)
    {
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        ExcelUtil<Introduction> util = new ExcelUtil<Introduction>(Introduction.class);
        util.exportExcel(response, list, "公司介绍数据");
    }

    /**
     * 获取公司介绍详细信息
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(introductionService.selectIntroductionById(id));
    }

    /**
     * 新增公司介绍
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:add')")
    @Log(title = "公司介绍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Introduction introduction)
    {
        return toAjax(introductionService.insertIntroduction(introduction));
    }

    /**
     * 修改公司介绍
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:edit')")
    @Log(title = "公司介绍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Introduction introduction)
    {
        return toAjax(introductionService.updateIntroduction(introduction));
    }

    /**
     * 删除公司介绍
     */
    @PreAuthorize("@ss.hasPermi('introduction:introduction:remove')")
    @Log(title = "公司介绍", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(introductionService.deleteIntroductionByIds(ids));
    }

    @Anonymous
    @GetMapping("/list1")
    public TableDataInfo list1(Introduction introduction)
    {
        startPage();
        List<Introduction>list = introductionService.selectIntroductionList(introduction);
        return getDataTable(list);
    }

}
